| Total Complexity | 14 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import {chat_v1 as chatV1} from '@googleapis/chat'; |
||
| 4 | |||
| 5 | export default abstract class BaseHandler { |
||
| 6 | protected event: chatV1.Schema$DeprecatedEvent; |
||
| 7 | |||
| 8 | constructor(event: chatV1.Schema$DeprecatedEvent) { |
||
| 9 | this.event = event; |
||
| 10 | } |
||
| 11 | |||
| 12 | protected getAnnotations(): chatV1.Schema$Annotation[] { |
||
| 13 | return this.event.message?.annotations ?? []; |
||
| 14 | } |
||
| 15 | |||
| 16 | protected getAnnotationByType(type: string): chatV1.Schema$Annotation | undefined { |
||
| 17 | return this.getAnnotations().find((annotation) => annotation.type === type); |
||
| 18 | } |
||
| 19 | |||
| 20 | protected getUserTimezone(): LocaleTimezone { |
||
| 21 | if (this.event.common?.timeZone?.id) { |
||
| 22 | const locale = this.event.common.userLocale ?? 'en'; |
||
| 23 | const id = this.event.common.timeZone.id; |
||
| 24 | const offset = this.event.common.timeZone.offset ?? 0; |
||
| 25 | return {locale, id, offset}; |
||
| 26 | } |
||
| 27 | |||
| 28 | return DEFAULT_LOCALE_TIMEZONE; |
||
| 29 | } |
||
| 30 | |||
| 31 | public abstract process(): chatV1.Schema$Message | Promise<chatV1.Schema$Message>; |
||
| 32 | } |
||
| 33 |